//
//  OptionViewController.m
//  NewTimer
//
//  Created by Moonbeom Kwon on 7/8/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "OptionViewController.h"

@interface OptionViewController ()

@end

@implementation OptionViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction) sendEmailToDeveloper: (id)sender
{
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
    mailView.mailComposeDelegate = self;
    [mailView setSubject:@"New Timer : Bug Report"];
    [mailView setToRecipients:[NSArray arrayWithObject:@"maskkwon@gmail.com"]];
    [self presentViewController:mailView animated:YES completion:NULL];
}

-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result) {
        case MFMailComposeResultSent:
            [[[UIAlertView alloc] initWithTitle:@"성공" message:@"성공적으로 보냈습니다" delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil] show];
            break;
            
        case MFMailComposeResultFailed:
            [[[UIAlertView alloc] initWithTitle:@"실패" message:@"전송에 실패하였습니다" delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil] show];
            break;
            
        default:
            break;
    }
    
    [controller dismissViewControllerAnimated:YES completion:NULL];
}

@end
